package com.gxa.riders.config;


import io.swagger.annotations.ApiOperation;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;


/**
 * @Author：wf
 * @Date: 2021/6/2 10:15
 * @Description:
 */
@Configuration
//@EnableSwagger2
public class Swagger3Config {
    //ture 启用Swagger3.0 fasle 禁用（生产环境要禁用）
    Boolean swaggerEnabled=true;

    @Bean
    public Docket createRestApi(){
        return new Docket(DocumentationType.OAS_30)
                .apiInfo(apiInfo())
                // 是否开启
                .enable(swaggerEnabled)
                .select()
                // 扫描的路径使用@Api的controller
                .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
                // 指定路径处理PathSelectors.any()代表所有的路径
                .paths(PathSelectors.any())
                .build()
                .groupName("蔚枫");
    }

    private ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                .title("Swagger3接口文档")
                .description("适用于前后端分离统一的接口文档")
                //作者信息
                //.contact(new Contact("name","url", "email"))
                .contact(new Contact("蔚枫","www.weifeng.cn", "675499307@qq.com"))
                .version("1.0")
                .build();
    }


    /*@Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .pathMapping("/")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.gxa.o2o.riders.controller"))
                .paths(PathSelectors.any())
                .build().apiInfo(new ApiInfoBuilder()
                        .title("骑手端管理接口")
                        .description("Swagger测试o2o项目")
                        .version("9.0")
                        .contact(new Contact("wf","http://www.蔚枫.top","675499307.com"))
                        .license("The Apache License")
                        .licenseUrl("http://www.sssss.com")
                        .build());
    }*/
}
